import request from '@/utils/request'

// 源码模式接口
export function SourceCodeTreeList(id) {
    return request({
        url: `/projectManage/project/tree/${id}`,
        method: 'post',
    })
}
// 源码模式根据文件当前菜单的ID查询文件对应的内容接口
export function projectgetContent(id) {
    return request({
        url: `/projectManage/project/getContent/${id}`,
        method: 'post',
    })
}

// 模块模式接口
export function moduleModetTreeList(id) {
    return request({
        url: `/projectManage/project/comTree/${id}`,
        method: 'post',
    })
}

// java代码返现编辑保存接口
export function editingAndSaving(data) {
    return request({
        url: `/projectManage/projectModel/list`,
        method: 'post',
        data
    })
}
// 生成接口基础信息接口
export function GenerateInterface(data) {
    return request({
        url: `/generate/code_json/generate_interface`,
        method: 'post',
        data
    })
}
// 重新生成接口代码接口
export function update_generate_interface(id,data) {
  return request({
      url: `/generate/code_json/re_generate_interface?interfaceId=${id}`,
      method: 'post',
      data
  })
}
// 新增接口
export function handleSaveSure(data,id,moduleId) {
    return request({
        url: `/component/create_vo_class?projectId=${id}&moduleId=${moduleId}`,
        method: 'post',
        data
    })
}

// 循环控制中集合名称接口
export function nameTnLoopControl(data) {
    return request({
        url: `/projectManage/projectModel/list`,
        method: 'post',
        data
    })
}

// 组件弹出框确定接口
export function handleConentSure(data) {
    return request({
        url: `/component/create_component`,
        method: 'post',
        data
    })
}
// 组件弹出框编辑确定接口
export function handleUpdateConentSure(data) {
  return request({
      url: `/component/update_component`,
      method: 'post',
      data
  })
}
//数据库操作组件确定接口
export function createdbComponent({classId,data}) {
  return request({
      url: `/component/create_db_component?classId=${classId}`,
      method: 'post',
      data
  })
}
//数据库操作组件sql确定接口
export function createdbsqlComponent({classId,data}) {
  return request({
      url: `/component/create_db_sql_component?classId=${classId}`,
      method: 'post',
      data
  })
}
//
export function findAt_tribute_ByType(type,data) {
  return request({
      url: `/component/find_attribute_by_type?type=${type}`,
      method: 'post',
      data
  })
}

// 查找集合元素组件字段名接口
export function find_class_attribute(type,id) {
  return request({
      url: `/component/find_class_attribute?className=${type}&projectId=${id}`,
      method: 'post',
  })
}

export function componentClassjson(classId) {
    return request({
        url: `/component/class_json?classId=${classId}`,
        method: 'get',
    })
}

// 调用方法类名接口
export function methodClassName(data) {
    return request({
        url: `/component/find_can_use_class_detail`,
        method: 'post',
        data
    })
}


// 条件判断属性下拉框接口
export function params_Lists(data) {
    return request({
        url: `/component/find_can_use_attribute`,
        method: 'post',
        data
    })
}


//数据库组件中的接口
export function projectTableLists({tableName="",componentName="",operateType="",projectId}) {
    return request({
      url: `/component/jlcpComponentTableOperate/list_db_component?tableName=${tableName}&componentName=${componentName}&operateType=${operateType}&projectId=${projectId}`,
      method: 'post',
    })
  }

  export function projectcustomdelete(data) {
    return request({
      url: `/component/jlcpComponentTableOperate/delete`,
      method: 'post',
      data
    })
  }

  //数据库组件表名
  export function projectdatebaseLists(id) {
    return request({
      url: `/component/find_class_by_type?currentProjectId=${id}&classType=ENTITY`,
      method: 'post',
    })
  }

  //数据库组件新增保存接口内容
  export function projectAddQuery(data) {
    return request({
      url: `/component/jlcpComponentTableOperate/create_select`,
      method: 'post',
      data
    })
  }

  export function projectcustomUpdate(data) {
    return request({
      url: `/component/jlcpComponentTableOperate/create_update`,
      method: 'post',
      data
    })
  }

  export function projectcustomOperateDelete(data) {
    return request({
      url: `/component/jlcpComponentTableOperate/create_delete`,
      method: 'post',
      data
    })
  }

  export function projectcustomOperateSelectSql(data) {
    return request({
      url: `/component/jlcpComponentTableOperate/select_sql`,
      method: 'post',
      data
    })
  }

  export function findCanUseVo(id) {
    return request({
      url: `/component/find_can_use_vo?currentProjectId=${id}`,
      method: 'post',
    })
  }

  export function findCanUseService({currentProjectId,currentClassId}) {
    return request({
      url: `/component/find_can_use_service?currentProjectId=${currentProjectId}&currentClassId=${currentClassId}`,
      method: 'post',
    })
  }

  export function findCanUsedao({currentProjectId,currentClassId}) {
    return request({
      url: `/component/find_can_use_dao?currentProjectId=${currentProjectId}&currentClassId=${currentClassId}`,
      method: 'post',
    })
  }




  //新增短信或邮件通知模板名是否存在
  export function configItemExist(projectId,configItem) {
    return request({
      url: `/component/jlcpCodeConfig/config_item_exist?projectId=${projectId}&configItem=${configItem}`,
      method: 'post',
    })
  }
  //校验接口名是否存在
  export function requestNameExist(value,projectId) {
    return request({
      url: `/component/request_name_exist?name=${value}&projectId=${projectId}`,
      method: 'post',
    })
  }
  //创建属性，填写属性名的时候校验是否存在
  export function attributeNameExist({data,name}) {
    return request({
      url: `/component/attribute_name_exist?name=${name}`,
      method: 'post',
      data
    })
  }
  //循环控制集合类型为集合列表的集合名称接口
  export function findCollectionAttribute(data) {
    return request({
      url: `/component/find_collection_attribute`,
      method: 'post',
      data
    })
  }
  //循环控制集合类型为MAP列表的集合名称接口
  export function findMapAttribute(data) {
    return request({
      url: `/component/find_map_attribute`,
      method: 'post',
      data
    })
  }

  //选择模块下拉框数据
  export function listModulePackage(id,childrenProjectId) {
    return request({
      url: `projectManage/project/list_module_package?projectId=${id}&childrenProjectId=${childrenProjectId}`,
      method: 'post',
    })
  }

  //增加方法弹出框新增和更新接口
  export function componentCreateMethod(data,url) {
    return request({
      url,
      method: 'post',
      data
    })
  }

  //校验属性名是否存在
  export function voClassNameExist(name,id) {
    return request({
      url: `/component/vo_class_name_exist?name=${name}&projectId=${id}`,
      method: 'post',
    })
  }

  //增加方法弹出框接口
  export function addClassAttribute(attributeType,classId) {
    return request({
      url: `/component/add_class_attribute?attributeType=${attributeType}&classId=${classId}`,
      method: 'post',
    })
  }
  //显示全部源码
  export function generateClassCode(classId) {
    return request({
      url: `/generate/code_json/generate_class_code?classId=${classId}`,
      method: 'post',
    })
  }
  //显示部分源码
  export function generateSomeClassCode(classId) {
    return request({
      url: `/generate/code_json/generate_class_code?classId=${classId}`,
      method: 'post',
    })
  }

  // 查看该方法的实现接口
  export function showServiceImpl(classId) {
    return request({
      url: `/generate/code_json/generate_class_code?classId=${classId}`,
      method: 'post',
    })
  }

  // 点击API按钮列表接口
  export function jlcpInterfaceInfo(params) {
    return request({
      url: `/component/jlcpInterfaceInfo/findPage`,
      method: 'get',
      params
    })
  }

   // 实例赋值组接口
   export function findClassInstance(data) {
    return request({
      url: `/component/find_class_instance`,
      method: 'post',
      data
    })
  }

  // 增加全局属性接口
  export function addClassGlobalAttribute(classId,data) {
    return request({
      url: `/component/add_class_global_attribute?classId=${classId}`,
      method: 'post',
      data
    })
  }

  // 属性删除接口
  export function deleteClassGlobalAttribute(params) {
    return request({
      url: `/component/delete_class_global_attribute`,
      method: 'get',
      params
    })
  }

  // 属性编辑接口
  export function updateClassGlobalAttribute(classId,index,data) {
    return request({
      url: `/component/update_class_global_attribute?classId=${classId}&index=${index}`,
      method: 'post',
      data
    })
  }

  // 新增类保存接口
  export function componentCreateClass(packageName,data) {
    return request({
      url: `/component/create_class?packageName=${packageName}`,
      method: 'post',
      data
    })
  }

  // 消息通知下的组件新增接口
  export function jlcpCodeConfigSave(data) {
    return request({
      url: `/component/jlcpCodeConfig/save`,
      method: 'post',
      data
    })
  }
  // 消息通知下的组件编辑接口
  export function jlcpCodeConfigUpdate(data) {
    return request({
      url: `/component/jlcpCodeConfig/update`,
      method: 'post',
      data
    })
  }
  // 消息通知下的组件删除接口
  export function jlcpCodeConfigDelete(data) {
    return request({
      url: `/component/jlcpCodeConfig/delete`,
      method: 'post',
      data
    })
  }
  // 通知配置列表接口
  export function jlcpCodeConfigFindPage({projectId,configItem,configDesc}) {
    return request({
      url: `/component/jlcpCodeConfig/findPage?projectId=${projectId}&configItem=${configItem}&configDesc=${configDesc}`,
      method: 'get',
    })
  }
  // 消息通知下的组件编辑接口
  export function findConfigItem(projectId,configType) {
    return request({
      url: `/component/jlcpCodeConfig/find_config_item?projectId=${projectId}&configType=${configType}`,
      method: 'get',
    })
  }

  // 短信和邮件通知新增保存接口
  export function createSmsNotice({classId,data,type}) {
    return request({
        url: `/component/create_notice?classId=${classId}&type=${type}`,
        method: 'post',
        data
    })
  }

  // 添加周期性定时任务新增保存接口
  export function scheduleLoopTask(data) {
    return request({
        url: `/component/create_schedule_loop_task`,
        method: 'post',
        data
    })
  }
  // 添加周期或一次性定时任务
  export function findclassbyType(id) {
    return request({
      url: `/component/find_class_by_type?currentProjectId=${id}&classType=TASK`,
      method: 'post',
    })
  }

   // 新增定时任务流程
   export function createScheduleFlow({flowName,flowEnName,projectId,packageName,moduleId}) {
    return request({
      url: `/component/create_or_update_schedule_flow?flowName=${flowName}&flowEnName=${flowEnName}&projectId=${projectId}&packageName=${packageName}&moduleId=${moduleId}`,
      method: 'post',
    })
  }

  // 定时任务流程列表接口
  export function listScheduleFlow({flowName,projectId}) {
    return request({
      url: `/component/list_schedule_flow?flowName=${flowName}&projectId=${projectId}`,
      method: 'get',
    })
  }

  // 周期性定时任务列表接口
  export function listScheduleLoopTask({scheduleName,projectId}) {
    return request({
      url: `/component/list_schedule_loop_task?scheduleName=${scheduleName}&projectId=${projectId}`,
      method: 'get',
    })
  }

  // 添加一次性定时任务保存接口
  export function createSingleScheduleComponent(data,classId) {
    return request({
      url: `/component/create_single_schedule_component?classId=${classId}`,
      method: 'post',
      data
    })
  }

  // 点击画布调下面接口使右侧高亮
  export function codeJsongenerateCode(data,number,componentId) {
    return request({
      url: `/generate/code_json/generate_code?unitTypeIndex=${number}&componentId=${componentId}`,
      method: 'post',
      data
    })
  }

  //feign调用接口列表
  export function listFeignInterface({feignClientName,targetProjectName,requestName,projectId}) {
    return request({
      url: `/component/jlcpFeignInterfaceInfo/list_feign_interface?feignClientName=${feignClientName}&targetProjectName=${targetProjectName}&requestName=${requestName}&projectId=${projectId}`,
      method: 'post',
    })
  }

  // 检查是否有依赖
  export function checkProjectDependency(currentProjectId,dependencyProjectId) {
    return request({
      url: `/projectManage/projectConfig/check_project_dependency?currentProjectId=${currentProjectId}&dependencyProjectId=${dependencyProjectId}`,
      method: 'post',
    })
  }

  // 点击引入依赖
  export function addProjectDependency(currentProjectId,dependencyProjectId) {
    return request({
      url: `/projectManage/projectConfig/add_project_dependency?currentProjectId=${currentProjectId}&dependencyProjectId=${dependencyProjectId}`,
      method: 'post',
    })
  }

  // 选择目标接口
  export function listInterface(projectId) {
    return request({
      url: `/component/jlcpInterfaceInfo/list_interface?projectId=${projectId}`,
      method: 'post',
    })
  }

  // 选择目标接口
  export function jlcpFeignInterfaceInfosave(data) {
    return request({
      url: `/component/jlcpFeignInterfaceInfo/save`,
      method: 'post',
      data
    })
  }

  //接口逻辑
  export function findInterfaceClass(interfaceId) {
    return request({
      url: `/generate/code_json/find_interface_class?interfaceId=${interfaceId}`,
      method: 'get',
    })
  }

  // 配置管理依赖配置中的添加依赖
  export function pomAddDependency(data) {
    return request({
      url: `/pom/add_dependency`,
      method: 'post',
      data
    })
  }

  // 配置管理依赖配置中的删除依赖弹出框的数据
  export function pomListDependency(data) {
    return request({
      url: `/pom/list_dependency`,
      method: 'post',
      data
    })
  }

  // 配置管理依赖配置中的删除依赖接口
  export function pomDeleteDependency(data) {
    return request({
      url: `/pom/delete_dependency`,
      method: 'post',
      data
    })
  }

  // 选择子项目接口
  export function projectManageprojectModellist(projectId) {
    return request({
      url: `/projectManage/projectModel/list/${projectId}`,
      method: 'post',
    })
  }

// 方法体删除接口
export function deleteComponent(componentId,methodId) {
  return request({
    url: `/component/jlcpComponentInfo/delete_component?componentId=${componentId}&methodId=${methodId}`,
    method: 'post',
  })
}

//增加引入包
export function addClassImports(classId,data) {
  return request({
    url: `/component/add_class_imports?classId=${classId}`,
    method: 'post',
    data
  })
}
//删除引入包
export function deleteClassImports(classId,data) {
  return request({
    url: `/component/delete_class_imports?classId=${classId}`,
    method: 'post',
    data
  })
}


//删除方法
export function delete_method(methodId) {
  return request({
    url: `/component/jlcpMethodInfo/delete_method?methodId=${methodId}`,
    method: 'post',
  })
}

//方法体移动
export function remove_component_position(data) {
  return request({
    url: `/generate/code_json/remove_component_position`,
    method: 'post',
    data
  })
}
